<template>
  <div class="info">
    <div class="card_con">
      <div class="row mb15">
        <div class="l" @click="handleType">
          <i class="el-icon-circle-plus-outline"></i>添加分类
        </div>
        <div class="l" @click="handleGoods">
          <i class="el-icon-circle-plus-outline"></i>添加商品
        </div>
      </div>

      <el-table
        border
        :data="tableData"
        :header-cell-style="{
          'text-align': 'center',
        }"
        :cell-style="{ 'text-align': 'center' }"
        style="width: 100%"
        highlight-current-row
      >
        <!-- <el-table-column type="selection" min-width="5%"> </el-table-column> -->
        <el-table-column prop="id" label="id" min-width="5%"> </el-table-column>
        <el-table-column label="商品图" min-width="15%">
          <template slot-scope="scope">
            <div class="slt">
              <el-popover placement="right" width="200" trigger="hover">
                <img class="tbImg1" :src="scope.row.logo" alt="" />
                <img
                  class="tbImg"
                  slot="reference"
                  :src="scope.row.logo"
                  alt=""
                />
              </el-popover>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="hf_id" label="商品名称" min-width="20%">
        </el-table-column>
        <el-table-column prop="hf_id" label="商品说明" min-width="20%">
        </el-table-column>
        <el-table-column prop="hf_id" label="标签文字" min-width="20%">
        </el-table-column>
        <el-table-column prop="hf_id" label="原价" min-width="20%">
        </el-table-column>
        <el-table-column prop="hf_id" label="现价" min-width="20%">
        </el-table-column>
        <el-table-column prop="create_time" label="创建时间" min-width="20%">
        </el-table-column>
        <el-table-column label="操作" min-width="20%">
          <template slot-scope="scope">
            <div class="caozuo">
              <div
                class="handleEdit hand_cs"
                @click="handleEdit(scope.$index, scope.row)"
              >
                修改
              </div>
              <div
                class="handleDelete hand_cs"
                @click="handleDelete(scope.$index, scope.row)"
              >
                删除
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <Pagination
          :page="page"
          @onCurrentChange="handleCurrentChange"
          @onSizeChange="handleSizeChange"
        />
      </div>
    </div>
    <el-dialog
      :close-on-click-modal="false"
      title="添加分类"
      :visible.sync="typeDialog"
      width="700px"
    >
      <Type v-if="typeDialog" @handleClose="handleClose"></Type>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      title="添加商品"
      :visible.sync="goodsDialog"
      width="700px"
    >
      <AddGoods v-if="goodsDialog" @handleClose="handleClose"></AddGoods>
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      title="编辑商品"
      :visible.sync="editGoods"
      width="700px"
    >
      <EditGoods v-if="editGoods" @handleClose="handleClose"></EditGoods>
    </el-dialog>
  </div>
</template>

<script>
import Type from "./dialog/goods_type_dialog.vue";
import AddGoods from "./dialog/add_goods_dialog.vue";
import Pagination from "@/components/Pagination.vue";
import EditGoods from "./dialog/edit_goods_dialog.vue";
export default {
  components: { Pagination, Type, AddGoods, EditGoods },
  data() {
    return {
      shopKeeper: "",
      storeName: "",
      shopTypeId: 1,
      shopStateId: 1,
      time: "",
      page: {
        total: 0,
        pageNum: 1, // 当前页数
        pageSize: 10, // 每页的条数
      },
      shopState: [
        { id: 1, name: "启用" },
        { id: 2, name: "禁用" },
      ],
      shopType: [
        { id: 1, name: "入驻" },
        { id: 2, name: "自营" },
      ],

      tableData: [
        {
          id: "1",
          hf_id: "123243",
          tel: "18582669937",
          location: "成都市武侯区",
          logo: require("@/assets/1.png"),
          leixing: "入驻",
          status: "启用",
          create_time: "2022-5-19",
        },
        {
          id: "2",
          hf_id: "123243",
          tel: "18582669937",
          location: "成都市武侯区",
          logo: require("@/assets/1.png"),
          leixing: "入驻",
          status: "启用",
          create_time: "2022-5-19",
        },
      ],
      title: "",
      typeDialog: false,
      goodsDialog: false,
      editGoods: false, //编辑商品
    };
  },
  methods: {
    //添加分类
    handleType() {
      this.typeDialog = true;
    },
    //添加商品
    handleGoods() {
      this.goodsDialog = true;
    },
    handleClick(tab) {
      console.log(tab);
    },
    handleEdit() {
      this.editGoods = true;
    },
    // 每页 ${val} 条
    handleSizeChange(val) {
      //   this.$emit("onSizeChange", val);
    },
    // 当前页: ${val}
    handleCurrentChange(val) {
      //   this.$emit("onCurrentChange", val);
    },
  },
  created() {
    console.log(this.$route);
  },
};
</script>

<style lang="scss" scoped>
@import "@/style/index.scss";

.info {
  .title {
    font-size: 16px;
    margin-bottom: 13px;
  }
}
.pagination {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}
.el-select {
  width: 100%;
}

.tb {
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
}
.row {
  display: flex;
  border-radius: 2px;
  .l {
    padding: 8px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    font-size: 13px;
    i {
      margin-right: 6px;
      font-size: 13px;
    }
    &:hover {
      cursor: pointer;
    }
  }
  .l:nth-child(1) {
    border-right: 0;
  }
}
.caozuo {
  display: flex;
  justify-content: center;
  .handleDelete {
    margin-left: 20px;
  }
}
/deep/.el-dialog {
  height: 75%;
  .el-dialog__body {
    height: 78%;
    overflow: auto;
  }
}
</style>
